package com.test.jaxb;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Date;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

/**
 * JAXB 사용해서 java object 를 xml 로 매핑
 */
public class Java2XML {

	public static void main(String[] args) throws JAXBException, IOException {
		JAXBContext context = JAXBContext.newInstance(Person.class);
		Marshaller marshaller = context.createMarshaller();
		marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

		Person person = new Person("Anonymous", 32, new Date(1970, 1, 10), "employee");
		marshaller.marshal(person, new FileWriter("Person.xml"));
	}
}
